/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * FormPencatatanMemberBaru.java
 *
 * Created on Nov 16, 2011, 7:00:24 AM
 */
package Member;

import Entity.Member;
import java.sql.SQLException;
import java.util.Date;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author evan_utomo
 */
public class FormPencatatanMemberBaru extends javax.swing.JPanel {

    /** Creates new form FormPencatatanMemberBaru */
    public FormPencatatanMemberBaru() {
        initComponents();


    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel11 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        jSeparator2 = new javax.swing.JSeparator();
        idAnggotaLabel = new javax.swing.JLabel();
        namaText = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        dateChooser = new com.toedter.calendar.JDateChooser();
        idAnggotaText = new javax.swing.JTextField();
        noidentitas = new javax.swing.JLabel();
        noidenTextfield = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        alamatTextArea = new javax.swing.JTextArea();
        batalButton = new javax.swing.JButton();
        simpanButton = new javax.swing.JButton();

        setBackground(new java.awt.Color(102, 102, 255));
        setPreferredSize(new java.awt.Dimension(550, 374));
        setLayout(null);

        jLabel11.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        jLabel11.setText("Tanggal Lahir ");
        add(jLabel11);
        jLabel11.setBounds(120, 160, 100, 20);

        jLabel12.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        jLabel12.setText("Alamat");
        add(jLabel12);
        jLabel12.setBounds(120, 200, 90, 14);
        add(jSeparator2);
        jSeparator2.setBounds(284, 14, 0, 2);

        idAnggotaLabel.setText("Id Anggota");
        add(idAnggotaLabel);
        idAnggotaLabel.setBounds(120, 70, 100, 20);
        add(namaText);
        namaText.setBounds(230, 100, 180, 20);

        jLabel5.setFont(new java.awt.Font("Tahoma", 1, 24));
        jLabel5.setText("Detail Data Member Perpustakaan");
        add(jLabel5);
        jLabel5.setBounds(90, 20, 407, 29);
        add(dateChooser);
        dateChooser.setBounds(230, 160, 160, 20);

        idAnggotaText.setEditable(false);
        idAnggotaText.setText(ControllerMemberBaru.IDMember());
        idAnggotaText.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                idAnggotaTextActionPerformed(evt);
            }
        });
        idAnggotaText.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                idAnggotaTextPropertyChange(evt);
            }
        });
        add(idAnggotaText);
        idAnggotaText.setBounds(230, 70, 90, 20);

        noidentitas.setText("No identitas");
        add(noidentitas);
        noidentitas.setBounds(120, 130, 100, 14);

        noidenTextfield.setToolTipText("masukan berupa angka");
        add(noidenTextfield);
        noidenTextfield.setBounds(230, 130, 180, 20);

        jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Gambar/medium 130.png"))); // NOI18N
        add(jLabel2);
        jLabel2.setBounds(10, 10, 60, 60);

        jLabel3.setText("Nama ");
        add(jLabel3);
        jLabel3.setBounds(120, 100, 100, 14);

        alamatTextArea.setColumns(20);
        alamatTextArea.setRows(5);
        jScrollPane1.setViewportView(alamatTextArea);

        add(jScrollPane1);
        jScrollPane1.setBounds(230, 200, 220, 70);

        batalButton.setText("Batal");
        batalButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                batalButtonActionPerformed(evt);
            }
        });
        add(batalButton);
        batalButton.setBounds(300, 300, 90, 23);

        simpanButton.setBackground(new java.awt.Color(255, 255, 255));
        simpanButton.setText("Simpan");
        simpanButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                simpanButtonActionPerformed(evt);
            }
        });
        add(simpanButton);
        simpanButton.setBounds(200, 300, 80, 23);
    }// </editor-fold>//GEN-END:initComponents

private void simpanButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_simpanButtonActionPerformed

    try {
        String kode = idAnggotaText.getText();
        String nama = namaText.getText();
        String almt = alamatTextArea.getText();
        Date tgl = dateChooser.getDate();
        String noiden = noidenTextfield.getText();
        Member mem = new Member();
        mem.setIdAnggota(kode);
        mem.setNama(nama);
        mem.setNoIdentitas(noiden);
        mem.setTanggallahir(tgl);
        mem.setAlamat(almt);
        mem.saveDataMember();
        mem.showMessageValid();
        idAnggotaText.setText(ControllerMemberBaru.IDMember());
        namaText.setText(null);
        alamatTextArea.setText(null);
        noidenTextfield.setText(null);
        dateChooser.setDate(null);
    } catch (SQLException ex) {
        JOptionPane.showMessageDialog(null, "Data gagal ditambahkan!");
        // Logger.getLogger(DataPemasokForm.class.getName()).log(Level.SEVERE, null, ex);
    } catch (Exception e) {
        JOptionPane.showMessageDialog(null, "" + e.getMessage());
        //Logger.getLogger(DataPemasokForm.class.getName()).log(Level.SEVERE, null, ex);
    }
}//GEN-LAST:event_simpanButtonActionPerformed

private void batalButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_batalButtonActionPerformed
    idAnggotaText.setText(ControllerMemberBaru.IDMember());
    namaText.setText(null);
    alamatTextArea.setText(null);
    noidenTextfield.setText(null);
    dateChooser.setDate(null);

}//GEN-LAST:event_batalButtonActionPerformed

private void idAnggotaTextActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_idAnggotaTextActionPerformed
}//GEN-LAST:event_idAnggotaTextActionPerformed

private void idAnggotaTextPropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_idAnggotaTextPropertyChange
}//GEN-LAST:event_idAnggotaTextPropertyChange
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextArea alamatTextArea;
    private javax.swing.JButton batalButton;
    private com.toedter.calendar.JDateChooser dateChooser;
    private javax.swing.JLabel idAnggotaLabel;
    private javax.swing.JTextField idAnggotaText;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JSeparator jSeparator2;
    private javax.swing.JTextField namaText;
    private javax.swing.JTextField noidenTextfield;
    private javax.swing.JLabel noidentitas;
    private javax.swing.JButton simpanButton;
    // End of variables declaration//GEN-END:variables
}
